Skip to content

fix(web): bypass xterm for global terminal shortcuts#1580

Open
AriajSarkar wants to merge 7 commits intopingdotgg:mainfrom
AriajSarkar:fix/terminal-toggle
Open

fix(web): bypass xterm for global terminal shortcuts#1580
AriajSarkar wants to merge 7 commits intopingdotgg:mainfrom
AriajSarkar:fix/terminal-toggle

Conversation

@AriajSarkar
Copy link
Copy Markdown
Contributor

@AriajSarkar AriajSarkar commented Mar 30, 2026

What Changed

  • Plumbed the keybindings state down from ChatView.tsx into ThreadTerminalDrawer.tsx.
  • Updated attachCustomKeyEventHandler on the xterm.js instance to explicitly pass the shortcut context: { terminalFocus: true, terminalOpen: true }.
  • Returned false on global shortcut matches (terminal.toggle, terminal.new, terminal.split, terminal.close, diff.toggle) to bypass xterm input capture.

Why

When the terminal was focused, xterm.js eagerly captured shortcut combinations (e.g., intercepting Ctrl+J as an 0x0A Line Feed, or Ctrl+N as ^N).
This prevented the global application shortcut listeners in ChatView.tsx from ever receiving these specific keystrokes. By explicitly whitelisting these application-level combinations in the custom event handler and providing the correct when context, xterm safely ignores them and allows the keydown event to bubble up properly.

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes
  • I included a video for animation/interaction changes

Note

Medium Risk
Changes keyboard event handling when the embedded terminal is focused, which can subtly affect shortcut behavior and terminal input capture. Risk is contained to the web terminal drawer but could regress expected keystrokes if shortcut matching/context is wrong.

Overview
When an xterm.js terminal is focused, app-level shortcuts (terminal toggle/split/new/close and diff.toggle) are now allowed to bubble up instead of being consumed as terminal input.

This is done by plumbing resolved keybindings from ChatView into ThreadTerminalDrawer/TerminalViewport and updating attachCustomKeyEventHandler to detect those shortcuts (with context: { terminalFocus: true, terminalOpen: true }) and return false, while keeping existing in-terminal navigation/clear handling intact.

Written by Cursor Bugbot for commit dc9ac52. This will update automatically on new commits. Configure here.

Note

Bypass xterm key handling for global terminal shortcuts when terminal is focused

  • Adds a keybindings prop to TerminalViewport (via ThreadTerminalDrawer) so resolved keybindings flow from ChatView down to the xterm instance.
  • In attachCustomKeyEventHandler, key events matching toggle, split, new-tab, close, or diff shortcuts now return false, preventing xterm from consuming them and allowing higher-level handlers to fire.
  • Navigation and clear shortcuts remain handled inside the terminal as before.
  • Behavioral Change: when the terminal is focused, the listed global shortcuts no longer get swallowed by xterm.

Macroscope summarized dc9ac52.

@github-actions github-actions bot added the size:M 30-99 changed lines (additions + deletions). label Mar 30, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 30, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 7f2e6851-72bd-4362-af3c-8ce501f3703b

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions bot added the vouch:unvouched PR author is not yet trusted in the VOUCHED list. label Mar 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant